Skip to content

M6g: overlay presence (enter/exit motion, opaque boxes, scrim fade) and sheets; Style::motion (#107) - #164

Merged
samitbasu merged 5 commits into
mainfrom
m6g-presence
Nov 13, 2026
Merged

samitbasu merged 5 commits into
mainfrom
m6g-presence

Conversation

@samitbasu

Copy link
Copy Markdown
Owner

M6 PR 6a: overlay presence (enter and exit motion) and sheets (#107). docs/overlays.md gains an As built in PR 6a section.

API (overlay chain)

  • .shown(Shown) (Shown { Open, Closed }, with no From<bool>, per CLAUDE.md).
  • Timing: .transition(Duration) and .exit_transition(Duration).
  • Easing: .easing(..) and .ease_*().
  • .entrance(Entrance):
    • Zoom: scale from 95% about the centre;
    • Pop: Zoom plus an 8 pt slide away from the anchor;
    • Slide(side): by the box's own size;
    • Fade: no box motion.
  • .on_exited(|app| ..): fires once, when the overlay is fully closed.
  • Style::motion: MotionStyle { popover, menu, dialog, sheet }. The neutral preset is instant. The shadcn preset: popover and menu Pop 150 ms; dialog Zoom 200 ms; sheet Slide 500 ms in, 300 ms out, InOut. These timings are approved on M6d: overlay presence (.shown/.transition/.entrance/.on_exited) and sheets #107.
  • shown is optional (a recorded deviation from §7). Without it, an overlay is open while declared and has no motion, so existing overlays are unchanged. Motion methods used without shown panic in debug builds.

Behaviour

  • The phase lives in Kept::presences, built on transition.rs's retargetable Progress, so there's no second clock. Reopening mid-exit reverses from the current progress.
  • Closed overlays aren't built: children isn't called.
  • Paint-only motion: layout and hit rects are final from frame 1.
  • Opaque boxes (decided on M6d: overlay presence (.shown/.transition/.entrance/.on_exited) and sheets #107): only a modal's scrim fades. Boxes zoom, pop or slide but are never faded, because without group opacity (Known differences from CSS: no rounded clipping, no group opacity #40) a per-shape fade blends unevenly.
  • Exiting overlays are inert but keep blocking the page, and aren't dismissed again or given keys. Focus returns when the exit has run.
  • An entering overlay is live: Esc dismisses it, and the motion reverses.
  • Stock widgets animate with the menu motion: the select list and dropdown menus. Submenus and context menus don't animate yet.
  • Sheets: Modal::Edge slides from its edge by default. The dialog example's dialog, confirm and sheet animate.
  • Continuity: the checker knows presence motion (Motion::Presents), so it isn't a false "teleport".

Behaviour changes to review

  • Entrance::SlideFade is gone; it became Slide.
  • Motion is #[non_exhaustive].
  • Tests that expected a closed modal, menu or select to vanish immediately now wait for the exit.
  • A LayoutState recreated every frame never animates; popup_style.rs now keeps its layout between frames.

Tests and goldens

  • tests/it/presence.rs: 20+ tests covering:

    • phase timing with a fixed step;
    • closed overlays not being built;
    • on_exited firing once;
    • reversal without a jump;
    • an exiting overlay blocking the page without being dismissed again;
    • Esc while entering and while exiting;
    • focus restore after the exit;
    • no repaint once settled;
    • the box staying opaque while the scrim fades (failed first);
    • a continuity timeline for a sheet opening and closing.

    Plus unit tests in src/presence.rs.

  • Goldens: all 124 unchanged; settled states are unaffected.

  • Frame strips of each motion can be regenerated from ignored tests (motion_strips_*).

cargo xtask ci passes, including the golden check.

Try it

The dialog example: open the dialog, the confirm and the sheet, and close them.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up

samitbasu and others added 5 commits November 12, 2026 20:30
The overlay chain gains .shown, .transition, .exit_transition, .easing,
.entrance and .on_exited. The library owns the Closed/Entering/Open/Exiting
phase in Kept, on the retargetable Transition of transition.rs, so a reopen
mid-exit reverses from where the box is. Children are not built while Closed.
Motion is paint-only at draw time (opacity per shape, scale about the centre,
slide by the box's own size); layout and hit rects are final from frame 1.

An exiting overlay is inert but its blocker stays live; it is not judged by
dismissal, takes no Esc/Return/Nav keys, and keeps its place in the stacking,
the focus trap and the focus restore until it is gone.

Style::motion (popover, menu, dialog, sheet) holds the defaults: instant
neutral, shadcn values in the preset. Modal::Edge sheets slide by default.
Motion::Presents lets the continuity checker accept the motion.

Behaviour changes: the dialog example's dialog, confirmation and sheet animate;
modal tests settle longer. `shown` is optional (no `shown` = declared means
open, no motion). Motion::Presents is a new (non-exhaustive) variant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
Both are always declared with shown(open), so they enter and leave with
Style::motion.menu (shadcn: fade, zoom and a short slide, 150 ms). Tests that
expect a closed list or menu to be gone settle for the exit first; the
popup_style test keeps its LayoutState between frames, as presence needs.
Submenus and the context menu still have no exit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
Without group opacity (#40) a per-shape fade lets the page show through the
box mid-motion, so only a modal's scrim fades. Fade, and the fade parts of
Zoom, Pop and the old SlideFade, no longer touch the box's opacity; SlideFade
is removed as the same as Slide. A Fade entrance has no motion of the box.

Shown has no From<bool> (no naked bool arguments): the dialog example's state
fields are Shown, and the stock select and menu map their open state
explicitly. shown stays optional (a deviation from section 7, recorded).
The shadcn timings are unchanged.

Behaviour changes: the box is never translucent while entering or leaving;
Entrance::SlideFade and Entry::SlideFade are gone; Shown::is_open added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
shadcn's overlays are bg-black/50, but they sit over a backdrop blur that
eggshell does not have (#40); alone, 50% barely separated a dialog from the
page, in dark mode especially. The user picked 80% from rendered candidates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
dialog, dialog_confirm, dialog_role_menu and sheet goldens change only by
the darker scrim behind the box.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant